package com.boot.controller;

import com.boot.commons.Result;
import com.boot.model.Pet;
import com.boot.model.UpVO;
import com.boot.model.User;
import com.boot.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/pet")
public class PetController {
    @Autowired
    private PetService petService;
    /**
     * 新增宠物信息
     * @param
     * @return
     */
  @PostMapping("/add")
    public Result addPet(@RequestBody Pet pet){
    petService.savePet(pet);
      return Result.success("新增宠物信息成功:"+pet);
    }
    /**
     *更新宠物信息
     */
    @PostMapping("/update")
    public Result updatePet(@RequestBody Pet pet){
        petService.updatePet(pet);
        return Result.success("修改宠物信息成功："+pet);
    }

    @DeleteMapping("/del/{id}")
    public Result delPet( @PathVariable String id){
        petService.delPet(id);
        return Result.success("删除id为"+id+"宠物信息成功");
    }
    @GetMapping("/query")
    public Result queryPet(){
        List<UpVO> Uplist = petService.queryPet();
        return Result.success(Uplist);
    }


}
